<template>
  <!-- 选择客户 -->
  <div>
    <el-form
      ref="queryParams"
      :model="queryParams"
      label-width="68px"
      class="card_0"
    >
      <el-row :gutter="15">
        <el-col :span="8">
          <el-form-item label="客户名称" prop="memberName">
            <el-input
              v-model="queryParams.memberName"
              placeholder="请输入客户名称"
              :maxlength="50"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="客户类型" prop="memberType">
            <el-select
              v-model="queryParams.memberType"
              placeholder="请选择客户类型"
              clearable
              size="small"
              @1change="handleQuery"
            >
              <el-option
                v-for="dict in dict.type.memberType"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
              />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="客户来源" prop="memberSource">
            <el-select
              v-model="queryParams.memberSource"
              placeholder="请选择客户来源"
              clearable
              size="small"
              @1change="handleQuery"
            >
              <el-option
                v-for="dict in dict.type.memberSource"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
              />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="手机号" prop="contactPhone">
            <el-input
              v-model="queryParams.contactPhone"
              placeholder="请输入手机号"
              :maxlength="11"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label-width="0px">
            <el-button
              type="primary"
              icon="el-icon-search"
              size="mini"
              @click="handleQuery"
              >搜索</el-button
            >
            <el-button icon="el-icon-refresh" size="mini" @click="ResetQuery"
              >重置</el-button
            >
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <el-table v-loading="loading" :data="list" height="400px" border>
      <el-table-column
        label="客户名称"
        align="center"
        prop="memberName"
        min-width="150"
        show-overflow-tooltip
      >
        <template slot-scope="scope">
          {{
            scope.row.memberType == 1
              ? scope.row.enterpriseName
              : scope.row.memberName
          }}
        </template>
      </el-table-column>
      <el-table-column
        label="客户类型"
        align="center"
        prop="memberType"
        min-width="150"
        show-overflow-tooltip
      >
        <template slot-scope="scope">
          <dict-tag
            :options="dict.type.memberType"
            :value="scope.row.memberType"
          />
        </template>
      </el-table-column>
<!--      <el-table-column-->
<!--        label="微信图像"-->
<!--        align="center"-->
<!--        min-width="150"-->
<!--        show-overflow-tooltip-->
<!--      >-->
<!--        <template slot-scope="{ row }">-->
<!--          <el-avatar :src="row.vxUrl"></el-avatar>-->
<!--        </template>-->
<!--      </el-table-column>-->
      <el-table-column
        label="客户来源"
        align="center"
        prop="memberSource"
        min-width="150"
        show-overflow-tooltip
      >
        <template slot-scope="scope">
          <dict-tag
            :options="dict.type.memberSource"
            :value="scope.row.memberSource"
          />
        </template>
      </el-table-column>
      <el-table-column
        label="手机号"
        align="center"
        prop="contactPhone"
        min-width="150"
        show-overflow-tooltip
      />
      <el-table-column
        label="操作"
        align="center"
        min-width="120"
        fixed="left"
        class-name="small-padding fixed-width"
      >
        <template slot-scope="scope">
          <el-button size="mini" type="text" @click="handleSelect(scope.row)"
            >选择</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <pagination
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
  <!-- </el-dialog> -->
</template>

<script>
import * as memberApi from '@/api/member/member'

export default {
  dicts: ['memberType', 'memberSource', 'memberStatus', 'censorStatus'],
  props: {
    show: {
      type: Boolean,
      default: false,
    },
    statusArr: {
      type: String,
      default: null,
    },
  },
  data() {
    return {
      loading: true,
      list: [],
      total: 0,
      queryParams: {
        memberName: '',
        pageNum: 1,
        pageSize: 10,
        //   censorStatus:2,
        // memberStatus: 1,
      },
    }
  },
  mounted() {
    this.getList()
  },
  methods: {
    getList() {
      this.loading = true
      memberApi.listBasic(this.queryParams).then((response) => {
        this.list = response.rows
        this.total = response.total
        this.loading = false
      })
    },
    handleQuery() {
      this.queryParams.pageNum = 1
      this.getList(this.queryParams)
    },
    ResetQuery() {
      this.resetForm('queryParams')
      this.queryParams = {
        memberName: '',
        pageNum: 1,
        pageSize: 10,
        // censorStatus:2,
        // memberStatus: 1,
      }
      this.handleQuery()
    },
    handleSelect(data) {
      this.loading = true
      memberApi.getBasic(data.memberNo).then((resopnse) => {
        let data = resopnse.data
        if (data.memberType == 1) {
          data.contactMember = data.memberName
          data.memberName = data.enterpriseName
        }
        this.$emit('success', data)
        this.loading = false
      })
    },
  },
}
</script>

<style>
</style>
